﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace DataAccessLayer.Models
{
    [MetadataType(typeof(CustomerMetadata))]
    public partial class Customer
    {
    }

    public class CustomerMetadata
    {
        [DisplayName("Name")]
        [Required(ErrorMessage = "Name is mandatory")]
        [StringLength(60, ErrorMessage="Name must be within 60 characters")]
        public string Name { get; set; }

        [DisplayName("Gender")]
        [Required(ErrorMessage = "Gender is mandatory")]
        public char Gender { get; set; }

        [DisplayName("Date Of Birth")]
        [Required(ErrorMessage = "Date Of Birth is mandatory")]
        [RegularExpression("^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9][0-9]$", 
            ErrorMessage = "Date of birth must be a number (DD-MM-YYYY")]
        public DateTime DOB { get; set; }

        [DisplayName("Home Phone")]
        [RegularExpression("^[0-9]+$", ErrorMessage = "Home Phone must be numeric characters")]
        [StringLength(15, ErrorMessage = "Home Phone must be within 15 characters")]
        public string HomePhone { get; set; }

        [DisplayName("Office Phone")]
        [RegularExpression("^[0-9]+$", ErrorMessage = "Office Phone must be numeric characters")]
        [StringLength(15, ErrorMessage = "Office Phone must be within 15 characters")]
        public string OfficePhone { get; set; }

        [DisplayName("Mobile Phone")]
        [Required(ErrorMessage = "Mobile Phone is mandatory")]
        [RegularExpression("^[0-9]+$", ErrorMessage = "Mobile Phone must be numeric characters")]
        [StringLength(15, ErrorMessage = "Mobile Phone must be within 15 characters")]
        public string MobilePhone { get; set; }

        [DisplayName("Email Address")]
        [Required(ErrorMessage = "Email Address is mandatory")]
        [RegularExpression("[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$",
            ErrorMessage="Email format is not valid")]
        [StringLength(20, ErrorMessage = "Email Address must be within 20 characters")]
        public string Email { get; set; }

        [DisplayName("Total Income")]
        public float TotalIncome { get; set; }

        [DisplayName("Other Obligation")]
        public float OtherObligation { get; set; }

        [DisplayName("ID Number")]
        [Required(ErrorMessage = "ID Number is mandatory")]
        [RegularExpression("^[A-Za-z0-9]+$", ErrorMessage="Only alphanumeric characters are allowed")]
        [StringLength(20, ErrorMessage = "ID Number must be within 20 characters")]
        public string IDNumber { get; set; }

        [DisplayName("ID Type")]
        [Required(ErrorMessage = "ID Type is mandatory")]
        public int IDTypeCode { get; set; }
    }
}
